#ifndef __ReadFile_hpp__
#define __ReadFile_hpp__

#include "InputStream.hpp"

namespace ge {

GE_DECLARE_CLASS( ReadFile );

//----------------------------------------------------------------------------//
// ReadFile
//----------------------------------------------------------------------------//

class ReadFile : public virtual InputStream
{
 friend class FileSystem;

 public:

     enum 
     { 
          BufferSize = 4096,
          Threshold = BufferSize >> 1, // 1/2 BufferSize 
     };

     virtual uint Read( void* _dst, uint _size );
     
     virtual uint ReadFrom( uint _offset, void* _dst, uint _size );

 protected:

     ReadFile( void );

     virtual ~ReadFile( void );

     void _Open( const String& _path ); // for FileSystem 
     
     virtual void _ApplyPos( void );

     void _ReadFrom_Impl( uint _offset, void* _dst, uint _size );

     void* m_handle;
     uint8 m_buffer[ BufferSize ];
     uint m_buffer_pos;
     uint m_buffer_size;
};

} // namespace ge

#endif//__ReadFile_hpp__
